export class Length {
    value
    unit

    constructor(value, unit) {
        this.value = value
        this.unit = unit
    }

    as(u) {
        let len = this;
        if (this.unit === "f") {
            if (u === "yard") {
                len = new Length(this.value / 3, u);
            } else if (u === "inch") {
                len = new Length(this.value * 12, u);
            }
        }

        if (this.unit === "yard") {
            if (u === "inch") {
                len = new Length(this.value * 36, u);
            } else if (u === "f") {
                len = new Length(this.value * 3, u);
            }
        }

        if (this.unit === "inch") {
            if (u === "f") {
                len = new Length(this.value / 12, u);
            } else if (u === "yard") {
                len = new Length(this.value / 36, u);
            }
        }

        return len;
    }

    getVal() {
        return this.value;
    }

    getUinnt() {
        return this.unit;
    }
}